from pymouse import PyMouseEvent


class MyMouseEvent(PyMouseEvent):
    def __init__(self):
        PyMouseEvent.__init__(self)
    '''
    实现click方法, 任何点击事件(包括点击和释放)都会触发click;
        x, y: 点击的坐标
        button: 0:左键 1:右键 2:中键
        press: True: 按住  False:释放
    '''
    def click(self, x, y, button, press):
        if button == 1:
            if press:
                print('left press')
            else:
                print('left release')
        else:  # if any other mouse button used
            print('not left click')

    '''
    实现run方法, 任何鼠标位移都会触发run;
        x, y: 移动的坐标
    '''
    def move(self, x, y):
        pass



# 监听鼠标事件
mouseListener = MyMouseEvent()
mouseListener.run()


# mouseListener.stop()